<template>
  <div>

    <el-row>
      <el-form
          inline
          label-position="left"
      >

        <!-- 所属区域 -->
        <el-form-item
            label="所属区域">
          <Select
              :flushFlag="resettingFlag"
              @SelectChange="districtChange"
              :options="districtOption"
          ></Select>
        </el-form-item>

      </el-form>
    </el-row>
  </div>
</template>

<script>
// --------------- element-ui ---------------------
import Select from "../../../../../components/element-ui/elSelect"
// ------------- axios ---------------------
import {getMobileOption} from "../../../../../api/work";

export default {
  components: {
    Select
  },
  data() {
    return {
      //  ----------- 查询表单 --------------
      resettingFlag: false, // 重置查询条件标识
      district: undefined,
      //  ------------ 查询项相关 ----------------
      districtOption: [{
        label: "全部",
        value: 0
      }],
    }
  },
  props: {
    Reset: {
      type: Boolean,
      default: false
    }
  },
  watch: {
    Reset: function () {
      this.resettingSelectOption()
    }
  },
  created() {
    this.getMobileOption();
  },
  methods: {
    // ------------- axios ----------------
    /**lolo
     * 下拉框选项
     * */
    getMobileOption: function () {
      getMobileOption()
          .then(res => {
            this.districtOption = res.data.data.district_copy;
            const optionDict = {
              district:res.data.data.district_copy,
              taizhan: res.data.data.taizhan_copy,
              freqCategory: res.data.data.freq_category_copy,
              mobile:res.data.data.mobile_copy,
              monitor:res.data.data.monitor_copy,
            }
            this.$emit("getOptionSuccess", optionDict);
          })
    },
    // -------------- 查询功能 --------------

    /**
     * 重置查询条件
     * */
    resettingSelectOption: function () {
      this.district = undefined;
      this.resettingFlag = !this.resettingFlag;
      this.$emit("resetSelectForm");
    },

    /**
     * 所属区域
     * @param val
     */
    districtChange: function (val) {
      if (val === 0) {
        this.$emit("resetSelectForm");
        return 0
      }
      this.district = val;
      const pd = {
        district: this.district
      }
      this.$emit("selectChange", pd);
    },
  }
}
</script>

<style>

.el-form {
  text-align: left;
}

.el-form-item {
  margin-left: 1.5vw;
}
</style>